﻿<%@ Page Language="C#" AutoEventWireup="true" CodeFile="quanlycauhoipoll.aspx.cs" MasterPageFile="~/Administrator/Admin.master" Inherits="Administrator_quanlycauhoipoll" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div style="width:95%; padding-left:20px" >
  <h2>&nbsp;</h2>
    <h2><a href="polls.aspx">Add Polls</a> :: <em>
      <span style="font-weight: normal; color: #0000CC">Edit Poll</span></em></h2>

    <asp:SqlDataSource ID="PollDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:up1vnConnectionString %>"
        SelectCommand="SELECT * FROM [Polls] WHERE ([PollID] = @PollID)" UpdateCommand="UPDATE Polls SET DisplayText = @DisplayText WHERE PollID = @PollID">
        <SelectParameters>
            <asp:QueryStringParameter Name="PollID" QueryStringField="pid" Type="Int32" />
        </SelectParameters>
        <UpdateParameters>
            <asp:Parameter Name="DisplayText" />
            <asp:Parameter Name="PollID" />
        </UpdateParameters>
    </asp:SqlDataSource>
    
    <asp:SqlDataSource ID="PollAnswersDataSource" runat="server" ConnectionString="<%$ ConnectionStrings:up1vnConnectionString %>"
        DeleteCommand="DELETE FROM [PollAnswers] WHERE [PollAnswerID] = @PollAnswerID"
        InsertCommand="INSERT INTO [PollAnswers] ([PollID], [DisplayText], [SortOrder]) VALUES (@PollID, @DisplayText, @SortOrder)"
        SelectCommand="SELECT * FROM [PollAnswers] WHERE ([PollID] = @PollID) ORDER BY [SortOrder]"
        UpdateCommand="UPDATE [PollAnswers] SET [DisplayText] = @DisplayText, [SortOrder] = @SortOrder WHERE [PollAnswerID] = @PollAnswerID">
        <DeleteParameters>
            <asp:Parameter Name="PollAnswerID" Type="Int32" />
        </DeleteParameters>
        <UpdateParameters>
            <asp:Parameter Name="DisplayText" Type="String" />
            <asp:Parameter Name="SortOrder" Type="Int32" />
            <asp:Parameter Name="PollAnswerID" Type="Int32" />
        </UpdateParameters>
        <SelectParameters>
            <asp:QueryStringParameter Name="PollID" QueryStringField="pid" Type="Int32" />
        </SelectParameters>
        <InsertParameters>
            <asp:QueryStringParameter Name="PollID" QueryStringField="pid" Type="Int32" />
            <asp:Parameter Name="DisplayText" Type="String" />
            <asp:Parameter Name="SortOrder" Type="Int32" />
        </InsertParameters>
    </asp:SqlDataSource>
    
    <p>
        <asp:DetailsView ID="DetailsView1" runat="server" AutoGenerateRows="False" DataKeyNames="PollID"
            DataSourceID="PollDataSource" DefaultMode="Edit" CellPadding="4" ForeColor="#333333" GridLines="None">
            <Fields>
                <asp:TemplateField HeaderText="Câu h&#7887;i Poll: ">
                    <EditItemTemplate>
                        <asp:TextBox ID="EditPollDisplayText" runat="server" Text='<%# Bind("DisplayText") %>' Columns="75" ValidationGroup="EditPollQuestion"></asp:TextBox>
                        <asp:RequiredFieldValidator ID="RequiredFieldValidator3" runat="server" ControlToValidate="EditPollDisplayText"
                            Display="Dynamic" ErrorMessage="B&#7841;n ph&#7843;i nh&#7853;p v&#259;n b&#7843;n cho câu h&#7887;i bình ch&#7885;n"></asp:RequiredFieldValidator>
                    </EditItemTemplate>
                </asp:TemplateField>
                <asp:CommandField ShowCancelButton="False" ShowEditButton="True" UpdateText="C&#7853;p nh&#7853;t câu h&#7887;i Poll" ValidationGroup="EditPollQuestion" />
            </Fields>
            <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <CommandRowStyle BackColor="#FFFFC0" Font-Bold="True" />
            <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
            <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
            <FieldHeaderStyle BackColor="#FFFF99" Font-Bold="True" />
            <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
            <AlternatingRowStyle BackColor="White" />
        </asp:DetailsView>
    </p>
    
    <div style="margin-left: 25px;">
        <p>
            <asp:DetailsView ID="PollAnswerInsert" runat="server" AutoGenerateRows="False" DataKeyNames="PollAnswerID"
                DataSourceID="PollAnswersDataSource" DefaultMode="Insert" CellPadding="4" ForeColor="#333333" GridLines="None">
                <Fields>
                    <asp:TemplateField HeaderText="Câu tr&#7843; l&#7901;i : " SortExpression="DisplayText">
                        <InsertItemTemplate>
                            <asp:TextBox ID="NewPollAnswerDisplayText" runat="server" Columns="75" Text='<%# Bind("DisplayText") %>'></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator2" runat="server" ControlToValidate="NewPollAnswerDisplayText" ValidationGroup="AddAnswer"
                                ErrorMessage="B&#7841;n ph&#7843;i nh&#7853;p v&#259;n b&#7843;n cho câu tr&#7843; l&#7901;i th&#259;m dò ý ki&#7871;n<br />" Display="Dynamic"></asp:RequiredFieldValidator>
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Th&#7913; t&#7921;: " SortExpression="SortOrder">
                        <InsertItemTemplate>
                            <asp:TextBox ID="NewPollAnswerSortOrder" runat="server" Columns="3" Text='<%# Bind("SortOrder") %>'></asp:TextBox>
                            <asp:CompareValidator ID="CompareValidator1" runat="server" ControlToValidate="NewPollAnswerSortOrder"
                                ErrorMessage="B&#7841;n ph&#7843;i nh&#7853;p m&#7897;t s&#7889; nguyên l&#7899;n h&#417;n ho&#7863;c b&#7857;ng s&#7889; 0.<br />" Operator="GreaterThanEqual"
                                Type="Integer" ValueToCompare="0" Display="Dynamic" ValidationGroup="AddAnswer"></asp:CompareValidator>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator4" runat="server" ControlToValidate="NewPollAnswerSortOrder"
                                Display="Dynamic" ErrorMessage="B&#7841;n ph&#7843;i cung c&#7845;p m&#7897;t giá tr&#7883; th&#7913; t&#7921; s&#7855;p x&#7871;p." ValidationGroup="AddAnswer"></asp:RequiredFieldValidator>
                        </InsertItemTemplate>
                    </asp:TemplateField>
                    <asp:CommandField InsertText="Thêm câu tr&#7843; l&#7901;i" ShowCancelButton="False" ShowInsertButton="True" ValidationGroup="AddAnswer" />
                </Fields>
                <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                <CommandRowStyle BackColor="#FFFFC0" Font-Bold="True" />
                <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                <FieldHeaderStyle BackColor="#FFFF99" Font-Bold="True" />
                <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" />
            </asp:DetailsView>
        </p>
        
        <p>
            <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="PollAnswerID"
                DataSourceID="PollAnswersDataSource" CellPadding="4" ForeColor="#333333" GridLines="None">
                <Columns>
                    <asp:CommandField ShowEditButton="True" ValidationGroup="EditAnswer" />
                    <asp:TemplateField ShowHeader="False">
                        <ItemTemplate>
                            <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="False" CommandName="Delete"
                                OnClientClick="return confirm('&#272;i&#7873;u này s&#7869; v&#297;nh vi&#7877;n xóa câu tr&#7843; l&#7901;i th&#259;m dò ý ki&#7871;n &#8203;&#8203;này và b&#7845;t k&#7923; phi&#7871;u liên quan. B&#7841;n có ch&#7855;c b&#7841;n mu&#7889;n làm &#273;i&#7873;u này?');"
                                Text="Xóa"></asp:LinkButton>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Câu h&#7887;i Poll" SortExpression="DisplayText">
                        <EditItemTemplate>
                            <asp:TextBox ID="EditPollAnswerDisplayText" runat="server" Columns="75" Text='<%# Bind("DisplayText") %>' ValidationGroup="EditAnswer"></asp:TextBox>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ControlToValidate="EditPollAnswerDisplayText"
                                Display="Dynamic" ErrorMessage="B&#7841;n ph&#7843;i nh&#7853;p v&#259;n b&#7843;n cho câu tr&#7843; l&#7901;i th&#259;m dò ý ki&#7871;n<br />"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label1" runat="server" Text='<%# Bind("DisplayText") %>'></asp:Label>
                        </ItemTemplate>
                    </asp:TemplateField>
                    <asp:TemplateField HeaderText="Th&#7913; t&#7921;" SortExpression="SortOrder">
                        <EditItemTemplate>
                            <asp:TextBox ID="EditPollAnswerSortOrder" runat="server" Columns="3" Text='<%# Bind("SortOrder") %>' ValidationGroup="EditAnswer"></asp:TextBox>
                            <asp:CompareValidator ID="CompareValidator2" runat="server" ControlToValidate="EditPollAnswerSortOrder"
                                Display="Dynamic" ErrorMessage="B&#7841;n ph&#7843;i nh&#7853;p m&#7897;t s&#7889; nguyên l&#7899;n h&#417;n ho&#7863;c b&#7857;ng s&#7889; 0..<br />"
                                Operator="GreaterThanEqual" Type="Integer" ValueToCompare="0"></asp:CompareValidator>
                            <asp:RequiredFieldValidator ID="RequiredFieldValidator5" runat="server" ControlToValidate="EditPollAnswerSortOrder"
                                Display="Dynamic" ErrorMessage="B&#7841;n ph&#7843;i nh&#7853;p m&#7897;t giá tr&#7883; th&#7913; t&#7921; s&#7855;p x&#7871;p" ValidationGroup="EditAnswer"></asp:RequiredFieldValidator>
                        </EditItemTemplate>
                        <ItemTemplate>
                            <asp:Label ID="Label2" runat="server" Text='<%# Bind("SortOrder") %>'></asp:Label>
                        </ItemTemplate>
                        <ItemStyle HorizontalAlign="Center" />
                    </asp:TemplateField>
                </Columns>
                <FooterStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                <RowStyle BackColor="#FFFBD6" ForeColor="#333333" />
                <SelectedRowStyle BackColor="#FFCC66" Font-Bold="True" ForeColor="Navy" />
                <PagerStyle BackColor="#FFCC66" ForeColor="#333333" HorizontalAlign="Center" />
                <HeaderStyle BackColor="#990000" Font-Bold="True" ForeColor="White" />
                <AlternatingRowStyle BackColor="White" />
            </asp:GridView>
        </p>
    </div>
    </div>
</asp:Content>
